package entities;

import java.util.ArrayList;

/**
 * Entity Class for Training Camps. Camp is a Event with a certain duration.
 * 
 * @author MK
 * @see entities.Event
 * 
 */
public class Camp extends Event {

	private int duration;

	public Camp() {
		super();

	}

	public Camp(Long date, Address place, ArrayList<Participant> participants,
			int duration) {
		super(date, place, participants);
		this.duration = duration;
	}

	public Camp(Camp camp) {
		this(camp.date, camp.place, camp.participants, camp.duration);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + duration;
		return result;
	}

	@Override
	public boolean equals(Object obj) {

		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Camp other = (Camp) obj;
		if (duration != other.duration)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Camp [duration=" + duration + ", date=" + date
				+ ", participants=" + participants + ", place=" + place + "]";
	}

	public int compareTo(Camp camp) {

		if (super.compareTo((Event) camp) != 0) {
			return super.compareTo((Event) camp);
		} else {
			return this.duration - camp.duration;
		}
	}

	public int getDuration() {
		return duration;
	}
}
